package com.lhz.framework.manager.threadManager;

import com.lhz.CustomizeApplicationContext;
import com.lhz.framework.manager.threadManager.factory.AsyncBean;
import com.lhz.project.system.model.entity.auth.OperateLog;
import com.lhz.project.system.service.base.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;

/**
 * spring 多例
 *
 * @author LiGezZ
 */
@Scope("prototype")
@Slf4j
public class OperateLogThreadManager extends BaseThreadManager {

    public OperateLogThreadManager(AsyncBean asyncBean, Object obj) {
        super(asyncBean, obj);
    }

    @Override
    public void run() {
        OperateLog operateLog = (OperateLog) asyncBean.getObject();
        //operateLog.setLocation(AddressUtils.getRealAddressByIP(operateLog.getIp()));
        CustomizeApplicationContext.getBean(LogService.class).insertOperateLog(operateLog);
    }
}
